package com.lagou.numsort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class NumSortMapper extends Mapper<LongWritable, Text, IntWritable,IntWritable> {
    private  IntWritable data = new IntWritable();
    private  IntWritable one = new IntWritable(1);

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //接收到文本内容，转为String类型
        String values = value.toString();
        data.set(Integer.parseInt(values));
        context.write(data,one);
    }
}
